from Project.HTools.encry.hash.hash_panel import HashPanel
import hashlib
import wx


class HashPanelMain(HashPanel):
    def __init__(self, parent):
        HashPanel.__init__(self, parent)

    def doCalc(self, event):
        data = self.edit_data.GetValue()
        if data == '':
            wx.MessageDialog(self, '待加密数据不能为空', '操作提醒', wx.OK).ShowModal()
        else:
            md5_object = hashlib.md5(data.encode())
            self.result_md5.SetValue(md5_object.hexdigest())

    def doClear(self, event):
        self.edit_data.SetValue('')
        self.result_md5.SetValue('')
